package card.specs;

public enum CardName {

    TWO(1) {
        @Override
        public String toString() {
            return "2";
        }
    },
    THREE(2) {
        @Override
        public String toString() {
            return "3";
        }
    },
    FOUR(3) {
        @Override
        public String toString() {
            return "4";
        }
    },
    FIVE(4) {
        @Override
        public String toString() {
            return "5";
        }
    },
    SIX(5) {
        @Override
        public String toString() {
            return "6";
        }
    },
    SEVEN(6) {
        @Override
        public String toString() {
            return "7";
        }
    },
    EIGHT(7) {
        @Override
        public String toString() {
            return "8";
        }
    },
    NINE(8) {
        @Override
        public String toString() {
            return "9";
        }
    },
    TEN(9) {
        @Override
        public String toString() {
            return "T";
        }
    },
    JACK(10) {
        @Override
        public String toString() {
            return "J";
        }
    },
    QUEEN(11) {
        @Override
        public String toString() {
            return "Q";
        }
    },
    KING(12) {
        @Override
        public String toString() {
            return "K";
        }
    },
    ACE(13) {
        @Override
        public String toString() {
            return "A";
        }
    };
    private final int id;

    CardName(int id) {
        this.id = id;
    }

    public int getCardId() {
        return id;
    }

    public static CardName fromValue(int id) {
        CardName[] values = CardName.values();
        for (CardName cardName : values) {
            if (cardName.id == id) {
                return cardName;
            }
        }
        return null;
    }
}
